package com.youbang.bsMgr.role.dao;

import com.youbang.bsMgr.role.model.RoleEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.UUID;

/***
 *  角色
 */
@Component
public class RoleDao {

    @Autowired
    private RoleMapper roleMapper ;
    /**
     * 根据主键删除
     * @param id
     * @return
     */
    public int deleteByPrimaryKey(int id) throws Exception{
        return   roleMapper.deleteByPrimaryKey(id);
    }

    /**
     * 插入
     * @param record
     * @return
     */
    public int insert(RoleEntity record)throws Exception{
        return roleMapper.insert(record);
    }



    /**
     * 查看详情
     * @param id
     * @return
     */

   public  RoleEntity selectByPrimaryKey(int id)throws Exception{
        return roleMapper.selectByPrimaryKey(id);
    }


    /**
     * 根据id更新
     * @param record
     * @return
     */
    public  int updateByPrimaryKey(RoleEntity record)throws Exception{
        return roleMapper.updateByPrimaryKey(record);
    }

    /**
     * 获取全部角色
     * @return
     * @throws Exception
     */
    public List<RoleEntity> GetAllRole(Integer pageSize,Integer startIndex, Integer pageIndex,String searchRoleName)throws Exception{
        return roleMapper.GetAllRole(startIndex+pageSize*pageIndex,startIndex,searchRoleName);
    }

    /**
     * 获取角色数量
     * @return
     */
    public int GetAllRoleCout(String searchRoleName){
        return roleMapper.GetAllRoleCout(searchRoleName);
    }
}
